package com.aos.erp.manager.remote.sys;

import com.alibaba.fastjson.JSONObject;
import com.aos.erp.common.bean.ResultBean;
import com.aos.erp.manager.remote.model.SynUser;
import com.aos.erp.manager.remote.model.User;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: erp
 * @description: 同步用户
 * @author: tanzhiyu
 * @create: 2018-11-19 11:18
 **/
@FeignClient(name = "${PERMISSION-SERVICE}"/*, url = "${PERMISSION-SERVICE-URL}"*/)
public interface SynUserService {

    /**
     * 同步用户
     *
     * @param synUser
     * @return
     */
    @PostMapping(value = "/sync/synUserInfo")
    ResultBean synUserInfo(@RequestBody SynUser synUser);

    /**
     * 同步用户删除
     *
     * @param appCode  应用appCode
     * @param username 用户账户
     * @return
     */
    @DeleteMapping(value = "/sync/deleteUser")
    ResultBean deleteUser(@RequestParam("appCode") String appCode, @RequestParam("username") String username);

    /**
     * 用户登录
     *
     * @param appCode
     * @param username 账号
     * @param password 密码
     * @return
     */
    @PostMapping(value = "/user/login")
    ResultBean userLogin(@RequestParam("appCode") String appCode, @RequestParam("username") String username, @RequestParam("password") String password);

    /**
     * 用户退出
     *
     * @param token 用户token
     * @return
     */
    @GetMapping(value = "/sync/logout")
    ResultBean userLoginOut(@RequestParam("token") String token);

    /**
     * 新增用户
     * @param orgNameList
     * @param orgIdList
     * @param roleIdList
     * @param roleNameList
     * @param username
     * @param password
     * @param salt
     * @param name
     * @param appCode
     * @param usernames
     * @return
     */
   /* @PostMapping(value = "/user/addUser")
    ResultBean addUser(@RequestBody User user);*/
    @PostMapping(value = "/user/addUser")
    ResultBean addUser(@RequestParam("orgNameList") List<String> orgNameList,@RequestParam("orgIdList") List<Long> orgIdList,
                       @RequestParam("roleIdList") List<Long> roleIdList,@RequestParam("roleNameList") List<String> roleNameList,
                       @RequestParam("username") String username,@RequestParam("password") String password,
                       @RequestParam("salt") String salt,@RequestParam("name") String name,@RequestParam("appCode") String appCode,
                       @RequestParam("usernames") String usernames, @RequestParam("state")Integer state);

    /**
     * 修改用户
     * @param orgNameList
     * @param orgIdList
     * @param roleIdList
     * @param roleNameList
     * @param username
     * @param password
     * @param salt
     * @param name
     * @param appCode
     * @param usernames
     * @return
     */
    @PostMapping(value = "/user/updateUser")
    ResultBean updateUser(@RequestParam("orgNameList") List<String> orgNameList,@RequestParam("orgIdList") List<Long> orgIdList,
                       @RequestParam("roleIdList") List<Long> roleIdList,@RequestParam("roleNameList") List<String> roleNameList,
                       @RequestParam("username") String username,@RequestParam("password") String password,
                       @RequestParam("salt") String salt,@RequestParam("name") String name,
                       @RequestParam("appCode") String appCode,@RequestParam("usernames") String usernames,@RequestParam("id") long id);

    /**
     * 根据username查询用户信息
     * @param username
     * @return
     */
    @GetMapping(value = "/user/queryByUserName")
    ResultBean queryByUserName(@RequestParam("username") String username);
}

